<?php $this->load->view(TEMPLATE_NAME.'/front/header'); ?>
<?php $this->load->view(TEMPLATE_NAME.'/front/side_left'); ?>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script src="<?php echo base_url(); ?>js/jquery.NobleCount.min.js"></script>
<script src="<?php echo base_url(); ?>js/ajaxfileupload.js"></script>
<script src="<?php echo base_url(); ?>js/si.files.js"></script>
<Script type="text/javascript" language="javascript">
    SI.Files.stylizeAll();
  $(document).ready(function(){
	var i = 2;
    $('#add_more').click(function(){
            $('#add_image').append('<div class="addfoto">'
									+'<div class="labelf"><br />'
									+'<strong class="purple">Image '+i+':</strong>'
									+'<br /><br /><br />'
									+'Caption: <br />'
									+'<span class="purple">(optional)</span>'
									+'</div><div class="fotor">'
									+'<div id="image" style="position:relative; float:left">'
									+'<div class="select_label"><label class="cabinet">'
									+'<input name="file_'+i+'" class="file" type="file" id="file_'+i+'" onchange="return ajaxFileUpload(this);"/>'
									+'</label></div>'
									+'<div style="float:left;position:relative"><img id="loading_'+i+'" src="<?php echo base_url()?>image/loading_blue.gif" style="display:none;position:absolute;z-index:1000;left:120px;top:18px" /></div>'
									+'</div>'
									+'<div id="img_'+i+'" class="select_image">' 
									+'<img src="<?php echo base_url()?>xhtml/img/blank3.gif" width="69" height="69">'             
									+'</div>'
									+'<div class="select_textarea"><textarea name="imagecaption[]" id="imagecaption_'+i+'"></textarea></div>' 
									+'</div></div>'
									+'<br>');        
            i++;            
		document.getElementById('formcount').value = i;
        return false;            
    });
   });    
function ajaxFileUpload(get_this){
    var this_id = get_this.id.split('_');
    var div_load = "#loading_" + this_id[1];
     
    $(div_load)
    .ajaxStart(function(){
        $(this).show();
    })
    .ajaxComplete(function(){
        $(this).hide();
        $(this).unbind("ajaxStart");
    });    
    
    var img = '#img_' + this_id[1];
    $.ajaxFileUpload({
        url:'<?php echo site_url('ajax_upload/upload_directory_image/upload/news_photo')?>/file/'+get_this.id,
        secureuri:false,       
        fileElementId: get_this.id,
        dataType: 'json',
        success: function (data, status){
            if(typeof(data.error) != 'undefined'){
                if(data.error != ''){                    
                    $(img).html(data.error);
                }else{            
                    $(img).html('<img src="<?php echo base_url();?>uploads/news_photo/crop/'+data.msg+'" width="69" height="69" /><br />'
                    +'<input type="hidden" name="upload[]" value="'+data.msg +'">'); //please remove static if image upload not working 
                }
            }
        },
        error: function (data, status, e){
            $(span).html(e);
        }
    });
}
</Script>
<style type="text/css" title="text/css">
.SI-FILES-STYLIZED label.cabinet
{
    width: 100px;
    height: 28px;
    background: url(<?php echo base_url()?>image/select_news.jpg) 0 0 no-repeat;

    display: block;
    overflow: hidden;
    cursor: pointer;
}

.greebackgrd{
    background-color:#80FF00;
}

.SI-FILES-STYLIZED label.cabinet input.file
{
    position: relative;
    height: 100%;
    width: auto;
    opacity: 0;
    -moz-opacity: 0;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
</style>
<div class="page">
<h2>Post News </h2>
<?php //$newsid = $this->session->userdata('newsid');
	//$imagecount = $this->News_model->getimagecount($newsid);  //get image count
?>
<!--<div class="clear"></div>-->
<?php $this->load->view(TEMPLATE_NAME.'/front/news_header'); 
?>

<!--<div>-->
<p class="phase"><strong>Photos</strong> - Include Photos with your News - <span class="purple">(Optional)</span></p> <!--</div>-->
<!--<div style="float:right"><span class="purple">--><a href="" class="r">&gt; Add photos to this article</a><!--</span></div>-->
<!--<div style="float:left; width:150px">--><strong>Photos in this gallery: <span class="purple">(<?php echo $imagecount[0]['imgcnt'] ?>)</span></strong><!--</div>-->
<!--<div class="clear"></div>-->
<hr class="mb0" />
<div id="photolistings">
	<?php 

if($getimagelistings)
{
	
    echo form_open('news/news_photos');
//Please remove static if image not showin 
	for($i=0;$i<count($getimagelistings);$i++)
	{
	?>
    <div class="news_fotolist" <?php if($getimagelistings[$i]['is_article_photo'] == '1') { ?>  style="background-color: #D9FF68;" <?php } ?>>
    <a class="edit" href="<?php echo site_url('news/news_photos/'.$getimagelistings[$i]['id']) ?>">>> Edit</a>
	<!--<div style="float:left; width:75px">-->
    <img src="<?php echo base_url();?>uploads/news_photo/crop/<?php echo $getimagelistings[$i]['news_image'] ?> " width="52" height="52"><!--</div>-->
	<!--<div style="float:left; width:40px; text-align:center; vertical-align:middle">-->
    <?php echo form_checkbox('imageid[]', ''.$getimagelistings[$i]['id'].'', FALSE); ?>
	 <!--</div>-->
	<!--<div style="float:left; width:388px">-->
    <p><?php echo $getimagelistings[$i]['image_caption'] ?></p> <!--</div><div style="float:left"> -->
    <!--<span class="purple"><a href="<?php echo site_url('news/news_photos/'.$getimagelistings[$i]['id']) ?>">>> Edit</a></span></div>-->
	<div class="clear"></div>
    </div><!-- fotolist -->
   
	<?php
	}

	?>
<div class="news_submit"><?php echo form_submit('photodelete', 'Delete'); ?> <?php //echo form_submit('photothumbactive','Select as Thumbnail','class="gr_btn"'); ?></div>
<?php echo form_close(); 
}?>
<p class="phase">Include Photos with your article  <span class="purple">(Optional)</span></p>
</div>
  <?php //echo form_open_multipart('news/news_photos'); 
    //$attributes = array('class' => 'posts longs');
    echo form_open_multipart('news/news_photos');?>
<!--<div class="clear"></div>
<div class="clear"></div>-->
<div class="addfoto"><!--<div>-->
<div class="labelf"><br />

    <!--<div>
		<div>
	<div>Include Photos with your article<span class="purple">(Optional)</span></div>--><!--image header -->
    <strong class="purple">Image 1:</strong>
    <br /><br /><br />
    Caption: <br />
    <span class="purple">(optional)</span>
    </div><!-- labelf -->
    <div class="fotor">
          
	<!--<div style="float:left; width:100px">Select Image</div>-->    
                <div id="image" style="position:relative; float:left">
                <div class="select_label"> 
                <label class="cabinet">
                    <input name="file_1" class="file" type="file" id="file_1" onchange="return ajaxFileUpload(this);"/>
                </label>
                </div>
                <div style="float:left; position:relative">

                <img id="loading_1" src="<?php echo base_url()?>image/loading_blue.gif" style="display:none;position:absolute;z-index:1450;left:0px;top:0px" />

                </div>
                </div>

               
     <!--</div>
	     <div class="clear"></div> 
	     <div style="float:left; width:100px">&nbsp;</div>style="left:float"--> 
         <div id="img_1" class="select_image"> 
            <img src="<?php echo base_url()?>xhtml/img/blank3.gif" width="69" height="69">             
        </div>
		<!--<div class="clear"></div> 
    	 <div style="float:left; width:100px">Caption<br /><span class="purple">Optional</span></div>
    	 <div style="float:left">-->
         <div class="select_textarea"><textarea name="imagecaption[]" id="imagecaption_1"></textarea></div> <!--</div>   
         <div class="clear"></div>
     </div>-->
     
     <!--<div class="clear"></div>-->
     </div><!-- fotor -->
     <div class="clear"></div>
     </div>
     <div id="add_image"></div>
     <!-- addfoto -->
     <div class="clear"></div>
      <span style="padding-left:120px;" id="toremove"><strong><a id="add_more" href="">+ Add another photo</a> </strong></span>
     <hr /><input type="hidden" name="formcount" id="formcount" value="" />
	<?php  if($getimagelistings)
{

	for($i=0;$i<count($getimagelistings);$i++)
	{
	?>
	 <?php echo form_hidden('imageid[]', ''.$getimagelistings[$i]['id'].'', FALSE); ?>
	<?php
	}
}
	?>
     
     <?php echo form_submit('photosubmit', 'Upload Photos'); ?>&nbsp;&nbsp;<?php echo form_submit('proceed', 'Submit'); ?> <!--</div>                
<div class="clear"></div>-->

<?php echo form_close(); ?>
<!--</div>-->
    <?php $this->load->view(TEMPLATE_NAME.'/front/footer_menu');?>
</div><!-- page -->

<?php $this->load->view(TEMPLATE_NAME.'/front/side_right');?> 
<?php $this->load->view(TEMPLATE_NAME.'/front/footer');?> 
